part of "../popup.dart";

/// 弹窗锁屏，此方法无法通过用户解除，只能由[Pages]解除
/// 但如果传入一个onLock函数，则函数完成时就会自动返回上一页
Future<void> popLock(String text, {Function? onLock}) async {
  pop(
    dismissable: false,
    builder: () => CardDialog(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          const Space(height: 10),
          Text(text, style: styleMedium.delta(fontSize: -2)),
          const Space(height: 10),
        ],
      ),
    ),
  );

  // 如果有onLock函数的话，则执行它，完成后解除锁屏
  if (onLock != null) {
    await onLock();
    Pages.back();
  }
}
